package com.smartwebx.ha.web.admin.module.screen.group;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Param;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.smartwebx.ha.biz.assign.HaGroupManager;
import com.smartwebx.ha.dal.assign.bean.HaGroup;

public class AjaxAddGroup {
	@Autowired
	private HaGroupManager haGroupManager;

	public void execute(@Param("data") String dateJson) throws Exception {
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
				false);
		HaGroup group=mapper.readValue(dateJson, HaGroup.class);
		
		if (group.getId() == null) {
			haGroupManager.addGroup(group);
		} else {
			haGroupManager.updateGroup(group);
		}
	}
}
